<?php
namespace App\Admin\Renderable;

use App\Models\WxPlate;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;


class PlateRender extends LazyRenderable
{
    public function grid(): Grid
    {
        return Grid::make(new WxPlate(), function (Grid $grid) {
            global $__MINI_GLOBAL_TENANT_ID__;
            if($__MINI_GLOBAL_TENANT_ID__ > 0){
                $grid->model()->where('tenant_id', '=', $__MINI_GLOBAL_TENANT_ID__);
            }
            $grid->column('plate_name')->editable();
            $grid->column('sort')->editable();
            $grid->column('plate_introduce');
            $grid->column('plate_state')->switch();
            $grid->model()->orderBy('id', 'desc');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->like('plate_name');
            });
        });
    }
}

